home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / DOSTIPS1.ZIP / DOSDATES.TXT < prev    next >
Text File  |  1985-11-24  |  8KB  |  158 lines

  1.                            Stamp Collecting
  2.           (PC Magazine Vol 4 No 7 April 2, 1985 User-to-User)
  3.  
  4.      The batch file, DT.BAT, redirects the date and time information 
  5. into a file or to a printer.  To stamp a file, enter DT FILENAME.  To 
  6. have the information appear on a listing, type DT PRN.  So that you 
  7. don't have to press the Enter key when DOS asks for a new date and 
  8. time, create a file called CR that contains nothing except a carriage 
  9. return.  To do this, type COPY CON:CR and then hit the Enter key twice, 
  10. then F6, and then the Enter key one more time.  Then type:
  11.           COPY CON:DT.BAT
  12.           DATE<CR>%1
  13.           TIME<CR>%1
  14. Hit the Enter key after each line, then F6 and the Enter key when 
  15. you're done.  If you want one file with just the date and time, create
  16. a DT1.BAT as follows:
  17.           COPY CON:DT1.BAT
  18.           DATE<CR>DATE
  19.           TIME<CR>TIME
  20.           COPY DATE+TIME %1
  21.      The prompts from both DATE and TIME are not redirected to the 
  22. output file.  DT.BAT works properly if you're sending the output to a 
  23. printer, but the time stamp will write over the date stamp if you're 
  24. sending it to a disk file.  DT1.BAT will work both if you send it to a 
  25. printer or a file.
  26.  
  27. -----------------------------------------------------------------
  28.                         New Dates for Old
  29.        (PC Magazine Vol 4 No 21 Oct 15, 1985 User-to-User)
  30.  
  31.      Here's a trick to put the current date and time stamp on any of
  32. your files.  Create a one-line batch file called STAMP.BAT with the
  33. line:  COPY %1/B,,+ %1 >NUL, where the ">NUL" suppresses spurious
  34. messages that inclusion of the duplicate filespec generates.  Then just
  35. type:  STAMP filename, substituting the name of the file whose date and
  36. time you want to change for "filename."  This also suppresses error
  37. messages such as "File not found."
  38.      Editor's Note:  This technique includes an improvement over the
  39. example in the DOS manual -- the addition of a /B that forces DOS to
  40. copy the entire length of the file as specified by the directory.  If
  41. you omit the /B and try this on a binary file with a ^Z(CHR$(26)) in
  42. it, COPY will stop copying as soon as it hits this character, which
  43. DOS assumes is a standard end-of-file marker.  The /B will work both
  44. for ASCII files and binary files.  DOS defaults to /B when copying
  45. without joining files together but defaults to /A when you ask COPY
  46. to concatenate several files.
  47.      When DOS concatenates files (using +), it records the current
  48. date and time in the directory.  If you concatenate source files
  49. without naming a result filename, COPY will add all the files it is
  50. joining to the end of the first file in the list of filenames to be
  51. joined.  Since STAMP.BAT uses only one source name, and no result
  52. names, the file is concatenated onto itself.
  53.      While DOS is strict about punctuation and syntax, the ,,+ works
  54. as well as the +,, that the DOS manual uses.  And, as the manual
  55. points out, don't restamp all the files on your disk by using *.* in
  56. place of the filename.  Finally, STAMP.BAT will work fine without the
  57. second %1.
  58.  
  59. -----------------------------------------------------------------
  60.                          Dating Your Documents
  61.             (PC Magazine Vol 4 No 11 May 28, 1985 PC Tutor)
  62.  
  63.      The simplest way to create on demand a kind of "date stamp" that 
  64. you can add to a document file is to type in the date yourself.  If you 
  65. want to create a program to do this, use the DOS DATE command with 
  66. redirected input and output.  This is a good way to learn about 
  67. redirection even if you don't use the program.
  68.      Consider a line such as:
  69.           A>DATE<CARRIAGE>TODAY
  70.      Here, CARRIAGE is a tiny text file that consists of one empty 
  71. line and a carriage return -- to simulate answering the DATE question 
  72. by pressing the enter key.  The < sign before the word CARRIAGE is a 
  73. redirect symbol that means: use the file CARRIAGE as an input source 
  74. (instead of the keyboard).  You can construct the CARRIAGE file with
  75. the COPY command:
  76.           A>COPY CON:CARRIAGE <Enter>
  77.           <Press any key again>
  78.           <Press F6><Enter>
  79.           A>
  80.      For this application you only need to create CARRIAGE once and 
  81. then leave it on the disk. Note that the file is only 2 characters 
  82. long (a carraige return and a Ctrl-Z end-of-file marker), through it 
  83. may take up 1025 bytes on your disk.
  84.      The > sign before the word TODAY means that DOS will create a file 
  85. named TODAY, putting the output of DATE into the file.  In current 
  86. jargon, the output of the program DATE has been "redirected" to the 
  87. file TODAY.  Having created the CARRIAGE file, when you now type your
  88. command:
  89.           DATE<CARRIAGE>TODAY
  90. you will find a TODAY file has been created with the following lines in 
  91. it:
  92.           Current date is 5-28-85
  93.           Enter new date (mm-dd-yy):
  94. This is exactly what DOS would have typed on the screen.
  95.      You can get a bit fancier and strip off the last line quite easily 
  96. using the DOS FIND program.  It is a DOS program (not an intrinsic 
  97. command), so FIND.EXE would need to be on the disk.  Instead of your 
  98. previous command line, type:
  99.           A>DATE<CARRIAGE FIND "Current">TODAY
  100. Now the TODAY file will only retain the first line of the DATE result 
  101. -- the line containing the word "Current".  This works by piping ( )
  102. the output of DATE to the FIND program.  FIND thus uses the output of
  103. DATE instead of the keyboard for input.  In this case, that looks like
  104. two lines of text.  FIND notices the word "Current" on line 1 and
  105. passes it to the file TODAY.  The second line has no such word and
  106. therefore gets swallowed up.
  107.      If you are trying to integrate this with your word processor get 
  108. the startup (AUTOEXEC) routine to run the line that creates the TODAY 
  109. file.  Almost every word processor will let you merge or include an 
  110. existing file (TODAY) with your current filt.  Then your printout will 
  111. always contain a single line saying:  Current date is Tue 5-28-1985 -- 
  112. updated, of course, each day.
  113.      On a PC-XT under DOS 2.1, you don't need to use the DOS "pipe," 
  114. FIND. The "Enter new date" appears on the screen only (and the carriage 
  115. return from CARRIAGE popped you past it) and was not transferred to the 
  116. TODAY file.
  117.  
  118. -----------------------------------------------------------------
  119.                      In Search of Lost Time
  120.          (PC Magazine Vol 4 No 25 Dec 10, 1985 PC Tutor)
  121.  
  122.      Persons tired of seeing lists of files dated 1/1/80 might want to
  123. use the DATECHK.COM file.  DATECHK.COM returns an "error" code that
  124. equals the year set in DOS minus 1980.  The batch file fragment shown
  125. below which you can add to your AUTOEXEC.BAT file to run when you
  126. boot up, uses this error code with an ERRORLEVEL check to continually
  127. ask for the date if it's still set at 1980.
  128.  
  129. echo off
  130. cls
  131. :getdate
  132. date
  133. datechk
  134. if errorlevel 1 goto gooddate
  135. echo Gimme a break ....
  136. echo                   It's not 1980 anymore.
  137. goto getdate
  138. :gooddate
  139.  
  140. DATECHK.COM:
  141.  
  142. A>DEBUG
  143. -A
  144. xxxx:0100  MOV  AH,2A
  145. xxxx:0102  INT  21
  146. xxxx:0104  MOV  AX,CX
  147. xxxx:0106  SUB  AX,7BC
  148. xxxx:0109  MOV  AH,4C
  149. xxxx:010B  INT  21
  150. xxxx:010D
  151. -N DATECHK.COM
  152. -R CX
  153. CX 0000
  154. :000D
  155. -W
  156. Writing 000D bytes
  157. -Q
  158.